package com.woniuxy.hrp.service.Serviceimpl;

import com.woniuxy.hrp.entity.Department;
import com.woniuxy.hrp.mapper.DepartmentMapper;
import com.woniuxy.hrp.service.DepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: hrph
 * @InterfaceName PermMapper
 * @description:权限Mapper
 * @author: WY
 **/
@Service
@Transactional
public class DepartServiceImpl implements DepartService {

    @Autowired
    private DepartmentMapper departmentMapper;

    //增加科室
    @Override
    public void add(Department department) {
        departmentMapper.add(department);
    }

    //根据id修改科室信息
    @Override
    public void update(Department department) {
        departmentMapper.updateByCondition(department);
    }


    //查询科室(根据id)
    @Override
    public Department findById(int id) {
        Department department = departmentMapper.getById(id);
        return department;
    }

    //根据医院id查询所有科室
    @Override
    public List<Department> findByHospitalId(int Hid) {
        List<Department> departments = departmentMapper.findByHospitalid(Hid);
        return departments;
    }
}
